{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "'''\n",
    "Question 1\n",
    "Question:\n",
    "Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included).The numbers obtained should be printed in a comma-separated sequence on a single line.\n",
    "'''\n",
    "res = []\n",
    "for i in range(2000,3201): # 结束要用3201\n",
    "    if i % 7 == 0 and i % 5 != 0:\n",
    "        res.append(str(i)) # print(i,end=',')\n",
    "print(','.join(res)) # print('\\b')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "'''\n",
    "Question 2\n",
    "Question:\n",
    "Write a program which can compute the factorial（阶乘） of a given numbers.The results should be printed in a comma-separated sequence on a single line.Suppose the following input is supplied to the program: 8 Then, the output should be:40320\n",
    "'''\n",
    "\n",
    "def fac(n):\n",
    "    res = 1\n",
    "    flag = 1 \n",
    "    while flag <= n:\n",
    "        res = res*flag\n",
    "        flag += 1\n",
    "    return res\n",
    "fac(8)\n",
    "\n",
    "def fact(n):\n",
    "    res = 1\n",
    "    for i in range(1,n+1):\n",
    "        res = res*i\n",
    "    return res\n",
    "fact(8)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "'''\n",
    "Question 3\n",
    "With a given integral number n, write a program to generate a dictionary that contains (i, i x i) such that is an integral number between 1 and n (both included). and then the program should print the dictionary.Suppose the following input is supplied to the program: 8\n",
    "Then, the output should be:\n",
    "{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}\n",
    "'''\n",
    "def fuc(n):\n",
    "    dict = {}\n",
    "    for  i in range(1,n+1):\n",
    "        dict[i] = i*i\n",
    "    return dict\n",
    "fuc(8)\n",
    "\n",
    "# for loop"
   ]
  }
 ]
}